#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
class QAction;
class QActionGroup;
class QMenu;
class QMdiArea;
class SpreadSheet;
QT_END_NAMESPACE

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget* parent = 0);
    ~MainWindow();

private:
    bool goToContinue();

    /**
      @brief create a new spreadsheet instance in MainWindow.
    */
    void newFile();

    /**
      @brief open a spreadsheet file by user.
    */
    void open();

    void save();

    /**
      @brief save file as another name by user.
    */
    bool saveAs();

    void init_actions();

    void init_menus();

    /**
      @brief add the spread instance to mdiarea.
      @param spread as the son instance of MainWindow.
    */
    void addSpreadSheet(SpreadSheet* spread);

    /**
      descr:return the active SpreadSheet.
      return:true return SpreadSheet instance;false return 0.
    */
    SpreadSheet* activeSpreadSheet();

private:
    Ui::MainWindow *ui;

    QAction* pActionNew;
    QAction* pActionOpen;
    QAction* pActionSave;
    QAction* pActionSaveAs;
    QAction* pActionClose;
    QAction* pActionExit;

    QMenu* pMenuFile;
    QMenu* pMenuWindow;

    QMdiArea* pMdiArea;

    QActionGroup* pActionGroup;
};

#endif // MAINWINDOW_H
